<template>
	<view class="content">
		<view v-if="isKefu">
			<view>请添加下图客服二维码</view>
			<view class="kefuName">{{kefuInfo.name}}</view>
			<view>
				<image :src="switchImg()" mode="" class="kefuPicture"></image>
			</view>
			<view class="weixinhao">客服微信号：{{isNull(kefuInfo.weixinhao)?'':kefuInfo.weixinhao}}<text style="padding: 0 0 0 25rpx;font-size: 20rpx;color: #2B85E4;" @click="fuzhi()">复制</text></view>
		</view>
		<view style="padding-top: 20rpx;text-align: center;" v-if="!isKefu">
			未找到客服
		</view>
	</view>
</template>

<script>
	import uniGoodsNav from '@/components/uni-goods-nav/uni-goods-nav.vue'
	export default {
		data() {
			return {
				kefuInfo:{},	//客服信息
				isKefu:true,	//是否存在客服
			}
		},
		methods:{
			switchImg(){
				if(this.kefuInfo.avatar!=null && this.kefuInfo.avatar!="")
					return this.host+"/image/supplierKefuQrcode/"+this.kefuInfo.avatar;
				else
					return '../../static/index/gm.png';
			},
			//复制客服微信号
			fuzhi(){
				if(this.kefuInfo.weixinhao.length>0){
					uni.setClipboardData({
						data: this.kefuInfo.weixinhao,
						success: function(){
							// uni.showToast({
							//   title: `复制成功`,
							//   icon: 'none'
							// })
						}
					})
				}
			},
			//得客服信息
			getKefu(daili){
				this.$http.get('/xieliankefu/getkefuForSupplier', {
					supplierId: daili,
				}).then(res => {
					if(res.data.code==200){
						this.kefuInfo = res.data.data;
					}else{
						// this.$u.toast("客服获取失败")
						this.isKefu = false;
					}
				})
			},
			//判空
			isNull(str){
				return str==null || str=="" || str==undefined
			}
		},
		onLoad(opt) {
			this.getKefu(opt.daili)
		},
	}
</script>

<style lang="scss" scoped>
	.content{
		text-align: center;
		margin-top: 20rpx;
		font-size: 35rpx;
	}
	.kefuName{
		margin-top: 20rpx;
		margin-bottom: 20rpx;
	}
	.kefuPicture{
		width: 400rpx;
		height: 400rpx;
	}
	.weixinhao{
		margin-top: 10rpx;
	}
</style>
